<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><{$Think.config.cfg_webname}></title>
    <link href="__CSS__/base.css" rel="stylesheet">
    <link href="__CSS__/school.css" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/custom/uimaker/easyui.css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/custom/uimaker/icon.css">
    <style>
    #formAdd table{ width:100%;}
    #formAdd table td{ padding:5px;}
    #formAdd table td.td-left{text-align: right; padding-right: 10px;}
    </style>

</head>
<body>
<div class="container">
    <table id="dg"></table>
</div>

<div class="container">

    <table id="cxdm"></table>

    <!-- 操作条 -->
    <div id="tb" style="padding:0 30px;">
        <div id="toolbar">
            <a href='<{:U("App/appDetial")}>/appid' class="easyui-linkbutton"  iconCls="icon-add">新增</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" onclick="delApp()">删除</a>
            <input id="searchcont" name="search" value="" placeholder="请输入.." style="height: 28px;"></input>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="searchApp()">搜索</a><hr style="border: 1px solid #ddd;" />
        </div>
    </div>
</div>

<script type="text/javascript" src="__PUBLIC__/custom/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/custom/jquery.easyui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/custom/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
    $(function(){
        index();
    });

    function index(){
        //加载数据
        var app = $('#searchcont').val();
        $('#cxdm').datagrid({
            title:'应用列表',
            width:'100%',
            height:$(window).height(),
            fitColumns:true,
            striped: true,
            checkOnSelect:true,
            singleSelect : true,
            queryParams:{
                app:app
            },
            frozenColumns:[[//在冻结列中加入多选框
                {field:'chek',checkbox:true}
            ]],
            url:'<{:U("App/applist")}>',
            loadMsg:'数据加载中请稍后……',
            pagination: false,
            rownumbers: false,
            pageSize:10,
            toolbar:'#tb',
            columns:[[
                {field:'appid',title: '应用ID',align: 'center',sortable:"true",width:50},
                {field:'app',title: '应用名称',align: 'center',width:100},
                {field:'description',title: '说明',align: 'center',width:100,hidden:'ture'},
                {field:'android_package',title: 'android安装包名',align: 'center',width:100},
                {field:'android_download',title: 'android下载地址',align: 'center',width:100},
                {field:'android_appsize',title: 'android安装包大小',align: 'center',width:100},
                {field:'ios_package',title: 'ios安装包名',align: 'center',width:100},
                {field:'ios_download',title: 'ios下载地址',align: 'center',width:100},
                {field:'ios_appsize',title: 'ios安装包大小',align: 'center',width:100},
                {field:'orderid',title: '排序',align: 'center',width:50},
                {field:'admin',title: '操作人',align: 'center',width:50,hidden:'ture'},
                {field:'createtime',title: '创建时间',align: 'center',width:100,hidden:'ture'},
                {field:'updatetime',title: '修改时间',align: 'center',width:100,hidden:'ture'},
                {field:'id',title: 'ID',align: 'center',width:100,hidden:'true'},
                {
                    field : 'icon',
                    title : '图标',
                    align : 'center',
                    width : 50,
                    formatter:function(value,row){
                        var str = "";
                        if(value!="" || value!=null){
                            str = "<img style=\"height: 50px;\" src=<{:C('WEBHOME')}>"+value+">";
                            return str;
                        }
                    }},
                {field:'operate',title: '操作',align: 'center',width:100,
                    formatter:function(val,row,index){
                       return "<a href = '<{:U("App/appDetial")}>/appid/"+row.appid+"'>查看详情</a>";
                    }
                },
            ]],
        });
    }


    function searchApp(){
        index();
    }

    function delApp(){
        var arr=$('#cxdm').datagrid('getSelections');
        var cc = arr[0];

        if(!cc){
            $.messager.alert('提示','请选择一条数据!');
            return false;
        }
        $.messager.confirm('提示', '确定删除?', function(r){
            if (r){
               var appid = cc.appid;
               $.ajax({
                    url:'<{:U("App/delApp")}>',
                    data:{
                        appid:appid,
                    },
                    success:function(result){
                        if (result.sta==1){
                            $.messager.alert('提示','删除成功!','info',function(){
                                reload();
                            });
                        } else {
                            $.messager.show({
                                title: '错误提示',
                                msg: result.msg
                            });
                        }
                    }
               })
            }
        });
    }

    function reload(){
        window.location.reload();
    }

</script>

</body>
</html>











